package com.mit.web.business.proxy
{
	import com.mit.web.business.remote.BaseService;
	import com.mit.web.business.remote.IInvokeResponder;
	import com.mit.web.config.Constants;
	import com.mit.web.config.DisplayConfiguration;
	import com.mit.web.vo.design.StyleVO;
	import com.mit.web.vo.design.TemplateVO;
	
	
	public class DesignProxy extends BaseService
	{
		private static var me:DesignProxy;

		
		public function DesignProxy()
		{
			super(Constants.REMOTE_OBJECT_DESIGN);
			if(me != null)
				throw new Error("Only one instance of this class is allowed, use getInstance() insteadof the constructor.");

		}
		
		public static function getInstance():DesignProxy{
			if(me == null)
				me = new DesignProxy();
			return me;
		} 
		
		public function getPagedStyles(pageNo:int, searchCode:String = null, searchState:String = null):IInvokeResponder{
			return invoke("retrievePagiedStyles", searchCode, searchState, pageNo, DisplayConfiguration.getInstance().PAGE_SIZE);
		}
		
		public function getStylesCount(searchCode:String = null, searchState:String = null):IInvokeResponder{
			return invoke("retrieveStylesCount",searchCode, searchState);
		}	
		
		public function saveStyle(style:StyleVO):IInvokeResponder{
			return invoke("updateStyle", style);
		}
		
		public function getStyleById(id:int):IInvokeResponder{
			return invoke("retrieveStyleById", id);
		}
		
		public function getPagedTemplates(pageNo:int, searchCode:String = null, searchState:String = null):IInvokeResponder{
			return invoke("retrievePagiedTemplates", searchCode, searchState, pageNo, DisplayConfiguration.getInstance().PAGE_SIZE);
		}
		
		public function getTemplatesCount(searchCode:String = null, searchState:String = null):IInvokeResponder{
			return invoke("retrieveTemplatesCount",searchCode, searchState);
		}		
		
		public function getTemplateDetails(templateId:int):IInvokeResponder{
			return invoke("retrieveTemplateDetails",templateId);
		}
		
		public function saveTemplate(template:TemplateVO):IInvokeResponder{
			return invoke("updateTemplate",template);
		}
		
		public function getTemplatesByStyle(styleId:int, state:String = null, excludedId:int = 0):IInvokeResponder{
			return invoke("retrieveTemplatesByStyle", styleId, state, excludedId);
		}
		
		public function getPagedSampleTasks(pageNo:int, searchCode:String = null, taskState:String = null):IInvokeResponder{
			return invoke("retrievePagedSampleTasks", searchCode, taskState, pageNo, DisplayConfiguration.getInstance().PAGE_SIZE);
		}
		
		public function getSampleTaskCount(searchCode:String = null, taskState:String = null):IInvokeResponder{
			return invoke("retrieveSampleTaskCount",searchCode, taskState);
		}	
		
		public function saveSampleTask(sample:StyleVO):IInvokeResponder{
			return invoke("saveSampleTask",sample);
		}
		public function approveSample(sample:StyleVO):IInvokeResponder{
			return invoke("approveSample",sample);
		}
		public function getPagedSpecTasks(pageNo:int, searchCode:String = null, taskState:String = null):IInvokeResponder{
			return invoke("retrievePagedSpecTasks", searchCode, taskState, pageNo, DisplayConfiguration.getInstance().PAGE_SIZE);
		}
		
		public function getSpecTaskCount(searchCode:String = null, taskState:String = null):IInvokeResponder{
			return invoke("retrieveSpecTaskCount",searchCode, taskState);
		}	
		
		public function saveSpecTask(sample:StyleVO):IInvokeResponder{
			return invoke("saveSpecTask",sample);
		}
		public function approveStyle(styleId:int):IInvokeResponder{
			return invoke("approveStyle",styleId);
		}
		public function deleteStyle(styleId:int):IInvokeResponder{
			return invoke("deleteStyle",styleId);
		}
		public function terminateStyle(styleId:int):IInvokeResponder{
			return invoke("terminateStyle",styleId);
		}
		public function getApprovedStyles(year:int, season:int):IInvokeResponder{
			return invoke("retrieveApprovedStyles", year, season);
		}
	}
}